package cn.com.oceansoft.osc.ms.service.impl;

import cn.com.oceansoft.osc.ms.schedule.dswebService.WeChatServiceStub;
import cn.com.oceansoft.osc.ms.schedule.entity.*;
import cn.com.oceansoft.osc.ms.utils.XMLUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import cn.ucox.web.framework.view.ApiResult;
import org.apache.commons.lang.StringUtils;
import cn.com.oceansoft.osc.ms.service.ICallPoliceService;
import cn.com.oceansoft.osc.ms.persistence.ICallPoliceMapper;

/**
 * Created by caobo on 2017/7/8.
 */
@Service
public class CallPoliceServiceImpl implements ICallPoliceService {

    @Resource
    ICallPoliceMapper iCallPoliceMapper;

    @Override
    public ApiResult getResult(Map<String, String> map) {
        Map<String, String> result = new HashMap<>();
        String ALARMGUID = map.get("ALARMGUID");//对应IO_WECHAT_ALARMRESULT表
        String OPENID = "";
        if (!StringUtils.isBlank(map.get("OPENID"))) {
            OPENID = map.get("OPENID");
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "OPENID不能为空");
            return new ApiResult().failure(result);
        }
        String CHECKTYPE = map.get("CHECKTYPE");
        String ACORGID = map.get("ACORGID");
        String ACORGNAME = map.get("ACORGNAME");
        String CHECKRESULT = map.get("CHECKRESULT");
        String CHECKDATE = map.get("CHECKDATE");
        String ALARMCODE = map.get("ALARMCODE");
        String REMARK1 = "";
        String REMARK2 = "";
        String REMARK3 = "";
        String REMARK4 = "";
        String REMARK5 = "";
        if (!StringUtils.isBlank(map.get("REMARK1"))) {
            REMARK1 = map.get("REMARK1");
        }
        if (!StringUtils.isBlank(map.get("REMARK2"))) {
            REMARK2 = map.get("REMARK2");
        }
        if (!StringUtils.isBlank(map.get("REMARK3"))) {
            REMARK3 = map.get("REMARK3");
        }
        if (!StringUtils.isBlank(map.get("REMARK4"))) {
            REMARK4 = map.get("REMARK4");
        }
        if (!StringUtils.isBlank(map.get("REMARK5"))) {
            REMARK5 = map.get("REMARK5");
        }
        CallPoliceAlarmResult callresult = new CallPoliceAlarmResult();
        String guid = UUID.randomUUID().toString();
        callresult.setGUID(guid);
        callresult.setALARMGUID(ALARMGUID);
        callresult.setOPENID(OPENID);
        callresult.setCHECKTYPE(CHECKTYPE);
        callresult.setACORGID(ACORGID);
        callresult.setACORGNAME(ACORGNAME);
        callresult.setCHECKRESULT(CHECKRESULT);
        callresult.setCHECKDATE(CHECKDATE);
        callresult.setALARMCODE(ALARMCODE);
        callresult.setREMARK1(REMARK1);
        callresult.setREMARK2(REMARK2);
        callresult.setREMARK3(REMARK3);
        callresult.setREMARK4(REMARK4);
        callresult.setREMARK5(REMARK5);
        int i = iCallPoliceMapper.insertAlarmResult(callresult);

        if (i > 0) {
            String msg = "";
            result.put("sucess", "T");
            result.put("errorCode", "保存成功");
            return new ApiResult().success(result);
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "保存失败");
            return new ApiResult().failure(result);
        }
    }

    @Override
    public String getResultxml(paras paraxml) {
        String ALARMGUID = paraxml.getGUID();// map.get("ALARMGUID");//对应IO_WECHAT_ALARMRESULT表
        String OPENID = paraxml.getOPENID();// map.get("OPENID");
        String CHECKTYPE = paraxml.getCHECKTYPE();// map.get("CHECKTYPE");
        String ACORGID =paraxml.getACORGID();// map.get("ACORGID");
        String ACORGNAME =paraxml.getACORGNAME();// map.get("ACORGNAME");
        String CHECKRESULT =paraxml.getCHECKRESULT();// map.get("CHECKRESULT");
        String CHECKDATE = paraxml.getCHECKDATE();// map.get("CHECKDATE");
        String ALARMCODE = paraxml.getALARMCODE();// map.get("ALARMCODE");
        String REMARK1="";
        String REMARK2="";
        String REMARK3="";
        String REMARK4="";
        String REMARK5="";
        if(!StringUtils.isBlank(paraxml.getREMARK1()))//map.get("REMARK1")))
        {
            REMARK1=paraxml.getREMARK1();
        }
        if(!StringUtils.isBlank(paraxml.getREMARK2()))
        {
            REMARK2=paraxml.getREMARK2();
        }
        CallPoliceAlarmResult callresult=new CallPoliceAlarmResult();
        String guid= UUID.randomUUID().toString();
        callresult.setGUID(guid);
        callresult.setALARMGUID(ALARMGUID);
        callresult.setOPENID(OPENID);
        callresult.setCHECKTYPE(CHECKTYPE);
        callresult.setACORGID(ACORGID);
        callresult.setACORGNAME(ACORGNAME);
        callresult.setCHECKRESULT(CHECKRESULT);
        callresult.setCHECKDATE(CHECKDATE);
        callresult.setALARMCODE(ALARMCODE);
        callresult.setREMARK1(REMARK1);
        callresult.setREMARK2(REMARK2);
        callresult.setREMARK3(REMARK3);
        callresult.setREMARK4(REMARK4);
        callresult.setREMARK5(REMARK5);
        int i= iCallPoliceMapper.insertAlarmResult(callresult);
        if(i>0)
        {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="保存成功";
            returnInfo.IsSuccess="True";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        else
        {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="保存失败";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
    }

    @Override
    public String getAlarmResultxml(parasalarmresult paraxml) {
        String GUID = "";
        if (!StringUtils.isBlank(paraxml.getGUID())) {
            GUID = paraxml.getGUID();
        } else {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="GUID不能为空";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        String ISACCEPT = "";
        if (!StringUtils.isBlank(paraxml.getISACCEPT())) {
            ISACCEPT = paraxml.getISACCEPT();
        } else {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="ISACCEPT不能为空";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        String ACCEPTDATE = "";
        if (!StringUtils.isBlank(paraxml.getACCEPTDATE())) {
            ACCEPTDATE = paraxml.getACCEPTDATE();
        } else {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="ACCEPTDATE不能为空";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        CallPoliceLog callPoliceLog=new CallPoliceLog();
        callPoliceLog.setGUID(UUID.randomUUID().toString());
        callPoliceLog.setCREATETIME(ACCEPTDATE);
        callPoliceLog.setUPSTATE(ISACCEPT);
        if(ISACCEPT=="0")
        {
            callPoliceLog.setMSG("接收失败");
        }
        else
        {
                callPoliceLog.setMSG("接收成功");
        }
        callPoliceLog.setXML("GUID:"+GUID+";ISACCEPT:"+ISACCEPT+";ACCEPTDATE:"+ACCEPTDATE);
        callPoliceLog.setRES("");
        callPoliceLog.setOPENID("");
        callPoliceLog.setTEMP1(GUID);
        callPoliceLog.setTEMP2("110ZHZX");
        callPoliceLog.setTEMP3("");
        int i= iCallPoliceMapper.insertLog(callPoliceLog);
        if(i>0)
        {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="成功";
            returnInfo.IsSuccess="True";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        else
        {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="失败";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
    }

    @Override
    public ApiResult InsertIoChat(Map<String, String> map) {
        Map<String, String> result = new HashMap<>();//对应IO_WECHAT_CHAT表
        String GUID = "";
        if (!StringUtils.isBlank(map.get("GUID"))) {
            GUID = map.get("GUID");
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "GUID不能为空");
            return new ApiResult().failure(result);
        }
        String PHONE = "";
        if (!StringUtils.isBlank(map.get("PHONE"))) {
            PHONE = map.get("PHONE");
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "PHONE不能为空");
            return new ApiResult().failure(result);
        }
        String OPENID = "";
        if (!StringUtils.isBlank(map.get("OPENID"))) {
            OPENID = map.get("OPENID");
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "OPENID不能为空");
            return new ApiResult().failure(result);
        }
        String CHANGETYPE = "";
        if (!StringUtils.isBlank(map.get("CHANGETYPE"))) {
            CHANGETYPE = map.get("CHANGETYPE");
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "CHANGETYPE不能为空");
            return new ApiResult().failure(result);
        }
        String CHANGECONTENT = "";
        if (!StringUtils.isBlank(map.get("CHANGECONTENT"))) {
            CHANGECONTENT = map.get("CHANGECONTENT");
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "CHANGECONTENT不能为空");
            return new ApiResult().failure(result);
        }
        String CHANGEDATE = "";
        if (!StringUtils.isBlank(map.get("CHANGEDATE"))) {
            CHANGEDATE = map.get("CHANGEDATE");
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "CHANGEDATE不能为空");
            return new ApiResult().failure(result);
        }
        String LATITUDE = "";
        if (!StringUtils.isBlank(map.get("LATITUDE"))) {
            LATITUDE = map.get("LATITUDE");
        }
        String LONGITUDE = "";
        if (!StringUtils.isBlank(map.get("LONGITUDE"))) {
            LONGITUDE = map.get("LONGITUDE");
        }
        String REMARK1 = "";
        if (!StringUtils.isBlank(map.get("REMARK1"))) {
            REMARK1 = map.get("REMARK1");
        }
        String REMARK2 = "";
        if (!StringUtils.isBlank(map.get("REMARK2"))) {
            REMARK2 = map.get("REMARK2");
        }
        String SRC = "";
        if (!StringUtils.isBlank(map.get("SRC"))) {
            SRC = map.get("SRC");
        }
        String STATUS = "";
        if (!StringUtils.isBlank(map.get("STATUS"))) {
            STATUS = map.get("STATUS");
        }
        CallPoliceChat callchat = new CallPoliceChat();
        String guid = UUID.randomUUID().toString();
        callchat.setGUID(guid);
        callchat.setALARMGUID(GUID);
        callchat.setPHONE(PHONE);
        callchat.setOPENID(OPENID);
        callchat.setCHANGETYPE(CHANGETYPE);
        callchat.setCHANGECONTENT(CHANGECONTENT);
        callchat.setCHANGEDATE(CHANGEDATE);
        callchat.setLATITUDE(LATITUDE);
        callchat.setLONGITUDE(LONGITUDE);
        callchat.setREMARK1(REMARK1);
        callchat.setREMARK2(REMARK2);
        callchat.setSRC(SRC);
        callchat.setSTATUS(STATUS);
        int i = iCallPoliceMapper.insertChat(callchat);
        if (i > 0) {
            String msg = "";
            result.put("sucess", "T");
            result.put("errorCode", "保存成功");
            return new ApiResult().success(result);
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "保存失败");
            return new ApiResult().failure(result);
        }
    }

    @Override
    public String InsertIoChatxml(paraschat paraschat) {
        Map<String, String> result = new HashMap<>();//对应IO_WECHAT_CHAT表
        String GUID = "";
        if (!StringUtils.isBlank(paraschat.getGUID())) {
            GUID = paraschat.getGUID();
        } else {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="GUID不能为空";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        String PHONE = "";
        if (!StringUtils.isBlank(paraschat.getPHONE())) {
            PHONE = paraschat.getPHONE();
        } else {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="PHONE不能为空";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        String OPENID = "";
        if (!StringUtils.isBlank(paraschat.getOPENID())) {
            OPENID = paraschat.getOPENID();
        } else {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="OPENID不能为空";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        String CHANGETYPE = "";
        if (!StringUtils.isBlank(paraschat.getCHANGETYPE())) {
            CHANGETYPE = paraschat.getCHANGETYPE();
        } else {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="CHANGETYPE不能为空";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        String CHANGECONTENT = "";
        if (!StringUtils.isBlank(paraschat.getCHANGECONTENT())) {
            CHANGECONTENT = paraschat.getCHANGECONTENT();
        } else {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="CHANGECONTENT不能为空";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        String CHANGEDATE = "";
        if (!StringUtils.isBlank(paraschat.getCHANGEDATE())) {
            CHANGEDATE = paraschat.getCHANGEDATE();
        } else {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="CHANGEDATE不能为空";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        String LATITUDE = "";
        if (!StringUtils.isBlank(paraschat.getLATITUDE())) {
            LATITUDE = paraschat.getLATITUDE();
        }
        String LONGITUDE = "";
        if (!StringUtils.isBlank(paraschat.getLONGITUDE())) {
            LONGITUDE = paraschat.getLATITUDE();
        }
        String REMARK1 = "";
        if (!StringUtils.isBlank(paraschat.getREMARK1())) {
            REMARK1 = paraschat.getREMARK1();
        }
        String REMARK2 = "";
        if (!StringUtils.isBlank(paraschat.getREMARK2())) {
            REMARK2 = paraschat.getREMARK2();
        }
        String SRC = "";
        if (!StringUtils.isBlank(paraschat.getSRC())) {
            SRC = paraschat.getSRC();
        }
        String STATUS = "";
        if (!StringUtils.isBlank(paraschat.getSTATUS())) {
            STATUS = paraschat.getSTATUS();
        }
        CallPoliceChat callchat = new CallPoliceChat();
        String guid = UUID.randomUUID().toString();
        callchat.setGUID(guid);
        callchat.setALARMGUID(GUID);
        callchat.setPHONE(PHONE);
        callchat.setOPENID(OPENID);
        callchat.setCHANGETYPE(CHANGETYPE);
        callchat.setCHANGECONTENT(CHANGECONTENT);
        callchat.setCHANGEDATE(CHANGEDATE);
        callchat.setLATITUDE(LATITUDE);
        callchat.setLONGITUDE(LONGITUDE);
        callchat.setREMARK1(REMARK1);
        callchat.setREMARK2(REMARK2);
        callchat.setSRC(SRC);
        callchat.setSTATUS(STATUS);
        int i = iCallPoliceMapper.insertChat(callchat);
        if(i>0)
        {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="保存成功";
            returnInfo.IsSuccess="True";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
        else
        {
            EpointDataBody EpointDataBody=new EpointDataBody();
            ReturnInfo returnInfo=new ReturnInfo();
            returnInfo.Msg="保存失败";
            returnInfo.IsSuccess="False";
            EpointDataBody.ReturnInfo=returnInfo;
            String res= XMLUtil.convertToXml(EpointDataBody);
            res= res.replace("epointDataBody","EpointDataBody");
            return  res;
        }
    }

    @Override
    public ApiResult updatealarmstate(Map<String, String> map) {
        Map<String, String> result = new HashMap<>();
        String ALARMGUID = map.get("ALARMGUID");//对应IO_WECHAT_ALARMRESULT表
        String OPENID = "";
        if (!StringUtils.isBlank(map.get("ALARMGUID"))) {
            OPENID = map.get("ALARMGUID");
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "ALARMGUID不能为空");
            return new ApiResult().failure(result);
        }
        String CHECKTYPE = map.get("CHECKTYPE");
        String ACORGID = map.get("ACORGID");
        String ACORGNAME = map.get("ACORGNAME");
        String CHECKRESULT = map.get("CHECKRESULT");
        String CHECKDATE = map.get("CHECKDATE");
        String ALARMCODE = map.get("ALARMCODE");
        String REMARK1 = "";
        String REMARK2 = "";
        String REMARK3 = "";
        String REMARK4 = "";
        String REMARK5 = "";
        if (!StringUtils.isBlank(map.get("REMARK1"))) {
            REMARK1 = map.get("REMARK1");
        }
        if (!StringUtils.isBlank(map.get("REMARK2"))) {
            REMARK2 = map.get("REMARK2");
        }
        if (!StringUtils.isBlank(map.get("REMARK3"))) {
            REMARK3 = map.get("REMARK3");
        }
        if (!StringUtils.isBlank(map.get("REMARK4"))) {
            REMARK4 = map.get("REMARK4");
        }
        if (!StringUtils.isBlank(map.get("REMARK5"))) {
            REMARK5 = map.get("REMARK5");
        }
        CallPoliceAlarmResult callresult = new CallPoliceAlarmResult();
        String guid = UUID.randomUUID().toString();
        callresult.setGUID(guid);
        callresult.setALARMGUID(ALARMGUID);
        callresult.setOPENID(OPENID);
        callresult.setCHECKTYPE(CHECKTYPE);
        callresult.setACORGID(ACORGID);
        callresult.setACORGNAME(ACORGNAME);
        callresult.setCHECKRESULT(CHECKRESULT);
        callresult.setCHECKDATE(CHECKDATE);
        callresult.setALARMCODE(ALARMCODE);
        callresult.setREMARK1(REMARK1);
        callresult.setREMARK2(REMARK2);
        callresult.setREMARK3(REMARK3);
        callresult.setREMARK4(REMARK4);
        callresult.setREMARK5(REMARK5);
        int i = iCallPoliceMapper.insertAlarmResult(callresult);

        if (i > 0) {
            String msg = "";
            result.put("sucess", "T");
            result.put("errorCode", "保存成功");
            return new ApiResult().success(result);
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "保存失败");
            return new ApiResult().failure(result);
        }
    }

    @Override
    public ApiResult getCallPolice(Map<String, String> map) {
        String ADDRESS = map.get("ADDRESS");//对应IO_WECHAT_ALARM表
        String CRCONTENT = map.get("CRCONTENT");
        String ISPHONE = map.get("ISPHONE");
        String USERCODE = map.get("USERCODE");
        String USERNAME = map.get("USERNAME");
        String USERPHONE = map.get("USERPHONE");
        String USERADDRESS = map.get("USERADDRESS");
        String UNITCONTACTOR = map.get("UNITCONTACTOR");
        String HANDPHONE = map.get("HANDPHONE");
        String TOORGID = map.get("TOORGID");
        String TOORGNAME = map.get("TOORGNAME");
        String COMNO = map.get("COMNO");
        String OPENID = map.get("OPENID");
        String EARTH_LONG = map.get("EARTH_LONG");
        String EARTH_LAT = map.get("EARTH_LAT");
        String STATE = map.get("STATE");
        String ALAMSTATE = map.get("ALAMSTATE");
        String REMARK1 = "";
        String REMARK2 = "";
        String REMARK3 = "";
        String REMARK4 = "";
        String REMARK5 = "";
        if (!StringUtils.isBlank(map.get("REMARK1"))) {
            REMARK1 = map.get("REMARK1");
        }
        if (!StringUtils.isBlank(map.get("REMARK2"))) {
            REMARK2 = map.get("REMARK2");
        }
        if (!StringUtils.isBlank(map.get("REMARK3"))) {
            REMARK3 = map.get("REMARK3");
        }
        if (!StringUtils.isBlank(map.get("REMARK4"))) {
            REMARK4 = map.get("REMARK4");
        }
        if (!StringUtils.isBlank(map.get("REMARK5"))) {
            REMARK5 = map.get("REMARK5");
        }
        CallPoliceAlarm callresult = new CallPoliceAlarm();
        String guid = UUID.randomUUID().toString();
        callresult.setGUID(guid);
        callresult.setADDRESS(ADDRESS);
        callresult.setCRCONTENT(CRCONTENT);
        callresult.setISPHONE(ISPHONE);
        callresult.setUSERCODE(USERCODE);
        callresult.setUSERNAME(USERNAME);
        callresult.setUSERPHONE(USERPHONE);
        callresult.setUSERADDRESS(USERADDRESS);
        callresult.setUNITCONTACTOR(UNITCONTACTOR);
        callresult.setHANDPHONE(HANDPHONE);
        callresult.setTOORGID(TOORGID);
        callresult.setTOORGNAME(TOORGNAME);
        callresult.setCOMNO(COMNO);
        callresult.setOPENID(OPENID);
        callresult.setEARTH_LONG(EARTH_LONG);
        callresult.setEARTH_LAT(EARTH_LAT);
        callresult.setSTATE(STATE);
        callresult.setALAMSTATE(ALAMSTATE);
        callresult.setREMARK1(REMARK1);
        callresult.setREMARK2(REMARK2);
        callresult.setREMARK3(REMARK3);
        callresult.setREMARK4(REMARK4);
        callresult.setREMARK5(REMARK5);
        int i = iCallPoliceMapper.insertAlarm(callresult);
        Map<String, String> result = new HashMap<>();
        if (i > 0) {
            String msg = "";
            result.put("sucess", "T");
            result.put("errorCode", "保存成功");
            return new ApiResult().success(result);
        } else {
            String msg = "";
            result.put("sucess", "F");
            result.put("errorCode", "保存失败");
            return new ApiResult().failure(result);
        }
    }
}
